#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(){
	//牌面初始化
	char point[13] = {'A','2','3','4','5','6','7','8','9','X','J','Q','K'};
	char type[4] = {'B','R','H','D'};//黑，红，花，片
	int num = 0,i = 0,po[52] = {};
	while(1){
		printf("你需要几张牌(1-52)：\n");
		scanf("%d",&num);
		if(num > 0 && num < 53) break;
		printf("请输入1-52张牌\n");
	}
	//发牌
	int arr[num]/*= {} */;//变长数组不能={}	
	srand(time(0));
	for(i = 0;i < num;i++){
		int index1 = rand() % 13;
		int index2 = rand() % 4;
		if(po[index1 + index2 * 13]){//牌发重了
			i--;
		}
		else{//没有重复
			printf("%c",type[index2]);
			printf("%c",po[index1]);
			printf("\n");
			po[index1 + index2 * 13] = 1;
			arr[i] = index1 + index2 * 13;
		}
	}
}
